<template>
  <div class="newsinfo-container">
    <h3 class="title">{{newInfoList.title}}</h3>
    <p class="info">
      <span>发表时间:{{newInfoList.add_time | dateFormat}}</span>
      <span>点击:{{newInfoList.click}}次</span>
    </p>
    <hr />
    <div class="content" v-html="newInfoList.content"></div>
    <comment-box :id="this.id"></comment-box>
  </div>
</template>
<script>
import { Toast } from "mint-ui";
import comment from "../subcomponents/comment.vue";

export default {
  data() {
    return {
      id: this.$route.params.id,
      newInfoList: []
    };
  },
  created() {
    this.getNewsInfo();
  },
  methods: {
    getNewsInfo() {
      this.axios.get("/api/getnew/" + this.id).then(response => {
        if (response.data.status === 0) {
          this.newInfoList = response.data.message[0];
        } else {
          Toast("新闻详情请求失败");
        }
      });
    }
  },
  components: {
    "comment-box": comment
  }
};
</script>
<style lang="scss">
.newsinfo-container {
  padding: 3px;
  .title {
    font-size: 15px;
    color: red;
    text-align: center;
    margin: 15px 0;
  }
  .info {
    color: #2266aa;
    display: flex;
    justify-content: space-between;
  }
}
</style>